package fr.ordre66.vlcs.web;

import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;


@Controller
@RequestMapping("/home")
public class Home {

	
    @RequestMapping(method = RequestMethod.GET)
    public String helloWorld(Model model) {
        
    	model.addAttribute("left", "home.jsp");
    	

    	try {
			@SuppressWarnings("unused")
			User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
			model.addAttribute("right", "menu.jsp");
		} catch (ClassCastException e) {
			model.addAttribute("right", "connexion.jsp");
		}
    	return "template";
    }
    
    @RequestMapping(method = RequestMethod.GET, value="/main")
    public String main(Model model) {        
    	return "home/main";
    } 

    @RequestMapping(method = RequestMethod.GET, value="/functionalities")
    public String functionalites(Model model) {        
    	return "home/functionalities";
    } 
    
    @RequestMapping(method = RequestMethod.GET, value="/howto")
    public String howto(Model model) {        
    	return "home/howto";
    } 
    
    @RequestMapping(method = RequestMethod.GET, value="/prices")
    public String prices(Model model) {        
    	return "home/prices";
    } 
}
